﻿<UserControl x:Class="Adalbertus.BudgetPlanner.Views.ExternalSources.IncomesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" 
>
    <ItemsControl ItemsSource="{Binding Incomes}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <GroupBox Margin="4">
                    <GroupBox.Header>
                        <WrapPanel>
                            <Label>Nazwa</Label>
                            <TextBox Text="{Binding Name}" Width="150" />
                            <Label>Łącznie</Label>
                            <Label Content="{Binding TotalValue}" />
                            <Button Content="X" ToolTip="Usuń źródło przychodów" cal:Message.Attach="[Event Click] = [Action RemoveIncome($dataContext)]"/>
                        </WrapPanel>
                    </GroupBox.Header>
                    <DataGrid ItemsSource="{Binding Entries}" CanUserAddRows="False" CanUserDeleteRows="False" 
                                          AutoGenerateColumns="False" MaxHeight="100" IsReadOnly="True"
                                          >
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Data" Binding="{Binding Date}" />
                            <DataGridTextColumn Header="Kwota" Binding="{Binding Value}" />
                        </DataGrid.Columns>
                    </DataGrid>
                </GroupBox>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</UserControl>
